import http from 'service/util/http.js'

export default {
    // 获取用户授信信息
    info(data) {
        return http.post('/user/info', data, ['userId'])
    },
    // 设置头像
    headImg(data) {
        return http.post('/user/headImg', data, ['userId', 'headImg'])
    },
    // 身份认证
    faceOrc(data) {
        // 不参加md5的参数 cardFrontImg cardBackImg faceBestImg
        return http.post('/user/face/ocr', data, ['userId'])
    },
    // 身份证确认
    faceVerity(data) {
        return http.post('/user/face/verity', data, ['userId'])
    },
    // 设置用户基本信息
    saveUserBase(data) {
        return http.post('/user/save/userBase', data, ['userId', 'education', 'nowAddress', 'profession',
            'yearIncome', 'companyName', 'companyProvince', 'companyCity', 'companyAddress', 'relationship',
            'relationshipName', 'relationshipTel', 'socialRelation', 'socialRelationName', 'socialRelationTel'])
    },
    // 提交用户信息审核
    submit(data) {
        return http.post('/user/submit', data, ['userId'])
    },
    // 查询用户身份证信息
    queryIdCard(data) {
        return http.post('/user/query/idCard', data, ['userId'])
    },
    // 查询基本信息
    queryUserBase(data) {
        return http.post('/user/query/userBase', data, ['userId'])
    },
    // 查询用户信息
    queryUserInfo(data) {
        return http.post('/user/query/userInfo', data, ['userId'])
    },
    // 获取用户红包
    redList(data) {
        return http.post('/user/red/list', data, ['userId', 'pageNo', 'pageSize'])
    },
    // 获取用户可用红包
    usableRedList(data) {
        return http.post('/user/usable/red/list', data, ['userId', 'pageNo', 'pageSize'])
    },
    // 获取用户免息券
    freeList(data) {
        return http.post('/user/free/list', data, ['userId', 'pageNo', 'pageSize'])
    },
    // 获取用户可用免息券
    usableFreeList(data) {
        return http.post('/user/usable/free/list', data, ['userId', 'pageNo', 'pageSize'])
    },
    // 获取消息列表
    messageList(data) {
        return http.post('/user/message/list', data, ['userId', 'pageNo', 'pageSize'])
    },
    // 查询用户是否配置通讯录,LBS
    config(data) {
        return http.post('/user/config', data, ['userId'])
    },
    // 添加通讯录
    telList(data) {
        /**
         *  不参与md5 json:通讯录
         */
        return http.post('/user/telList', data, ['userId'])
    },
    // 添加地理位置
    saveLbs(data) {
        return http.post('/user/save/lbs', data, ['longitude', 'latitude', 'scene', 'mobile', 'userId'])
    },
    // 添加用户设备ID
    client(data) {
        return http.post('/user/client', data, ['userId', 'clientId'])
    },
    // 邀请有礼
    invite(data) {
        return http.post('/user/invite', data, ['userId'])
    },
    // 职业列表
    professionList(data) {
        return http.post('/user/profession/list', data, ['userId']).then(res => {
            var { code, data } = res.data
            if (code == 'S') {
                var listNew = []
                var { list } = data
                for (var i = 0; i < list.length; i++) {
                    var item = list[i]
                    listNew.push({
                        value: item.code,
                        text: item.value
                    })
                }
                data.list = listNew
            }
            return res
        })
    },
    // 修改消息已读
    messageRead(data) {
        return http.post('/user/message/read', data, ['userId'])
    },
    // 添加指纹设备上送记录
    saveTokenKey(data) {
        return http.post('/user/save/token/key', data, ['userId', 'tokenKey'])
    }
}